<?php include './ketnoi.php';?>
<?php include 'cauhinh.php';?>
<html>
    <head>
        
    </head>
    <body>
        <?php
            $sql='select * from students';
            $students= okmen($sql);
        ?>
        <?php
            $sql='select * from stafft';
            $stafft=  okmen($sql);
        ?>
        <p>Bảng thông tin Students</p>
         <table width="200px" border="1" cellpacing="1">
             <tr>
                 <td width="20">so thu tu</td>
                  <td width="50">ho ten</td>
            </tr>
        <?php foreach ($students as $w):?>
            <tr>
                <td width="440"> <?php echo $w['id'] ?></td>
                
                <td width="730"> <?php echo $w['name'] ?> </td>
                <td ><input type="button" value="delete"></td>
                <td ><input type="button" value="Edit"></td>
                <td ><input type="button" value="Insert"></td>
                
            </tr>
          <?php endforeach;?>  
        </table>
         <p>Bảng thông tin Students</p>
         <table width="200px" border="1" cellpacing="1">
             <tr>
                 <td width="20">so thu tu</td>
                  <td width="50">ho ten</td>
            </tr>
        <?php foreach ($stafft as $w):?>
            <tr>
                <td width="450"> <?php echo $w['id'] ?></td>
                
                <td width="730"> <?php echo $w['name'] ?> </td>
                <td ><input type="button" value="delete"></td>
                <td ><input type="button" value="Edit"></td>
                <td ><input type="button" value="Insert"></td>
                
            </tr>
          <?php endforeach;?>  
        </table>
         
         <?php
          if(isset($_POST['submit']))
            {
                $name=mysql_real_escape_string($_POST['id']);
                $id=mysql_real_escape_string($_POST['name']);
                $query1=mysql_query("insert into add values('','$id','$name')");
                echo "insert into add values('','$id','$name')";
            ?>
            <fieldset style="width:300px;">
            <form method="post" action="">
                Id: <input type="text" name="id"><br>
                Name: <input type="text" name="name"><br>
                <br>
                <input type="submit" name="submit">
            </form>
            </fieldset>
         
         
         
         <?php
if(isset($_GET['id']))
{
    $id=$_GET['id'];
    if(isset($_POST['submit']))
    {
    $id=$_POST['id'];
    $name=$_POST['name'];
    $query3=mysql_query("update add set name='$name' where id='$id'");
    }
}
    <form method="post" action="">
        id:<input type="text" name="name" value="<?php echo $query2['id']; ?>" /><br />
        name:<input type="text" name="age" value="<?php echo $query2['name']; ?>" /><br /><br />
        <br />
        <input type="submit" name="submit" value="update" />
    </form>
    <?php
    }
    ?>
    </body>
</html>



